from selenium import webdriver
from time import sleep
import unittest
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys #键盘事件
from selenium.webdriver.support.select import Select #下拉菜单
from selenium.webdriver.common.by import By

class baidu(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.driver.get('https://www.jiuxian.com/')
        sleep(5)


    def tearDown(self) -> None:
        sleep(10)
        self.driver.quit()

    def test_01_jiuxian(self):
        # 1.点击请登录
        self.driver.find_element(By.LINK_TEXT, '请登录').click()
        sleep(2)
        # 2.输入账号
        self.driver.find_element(By.ID, 'userName').send_keys('17733058407')
        sleep(2)

        # 3.输入密码
        self.driver.find_element(By.XPATH, '//*[@id="password"]').send_keys('Li10140910')
        sleep(20)

        # 4.点击登录
        self.driver.find_element(By.NAME, 'bi_Usuallogin').click()
        sleep(2)
        # 6 点击 确定
        self.driver.find_element(By.XPATH, '//a[@id="bindSub"]').click()
        sleep(2)

    def test_02_jiuxian(self):
        self.test_01_jiuxian()
        sleep(2)
        self.driver.find_element(By.ID,'wd').send_keys('五粮液')
        sleep(2)



if __name__ == '__main__':
    unittest.main()